package com.aqie.easy.design;

import com.aqie.easy.structure.AVLTree2;
import com.aqie.easy.structure.NewNode;

/**
 * 706 设计哈希映射
 * put  get remove
 * todo 查看其它设计
 */
public class MyHashMap {
    private AVLTree2 AVlTree;
    private NewNode node = null;
    public MyHashMap() {
		AVlTree = new AVLTree2();
    }

    public void put(int key, int value) {
        node = AVlTree.insert(node, key, value);
    }

    public int get(int key) {
        NewNode nn = AVlTree.getAVLTree(key,node);
        if(nn!=null){
            return nn.val;
        }
        return -1;//不存在，返回-1
    }

    public void remove(int key) {
        node = AVlTree.deleteNode(node, key);
    }
}
